package com.example.diagnodroid;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class TabsPagerAdapter extends FragmentPagerAdapter {

	public final int MAX_TABS = 5;

	public TabsPagerAdapter(FragmentManager fm) {
		super(fm);
	}

	@Override
	public Fragment getItem(int arg0) {
		Fragment fragment = null;
		Bundle bundle = new Bundle();
		ArrayList<Test> arrayList = new ArrayList<Test>();
		int image = R.drawable.ic_launcher;
		
		switch (arg0) {
		case 0:
			arrayList.add(new Test(1, R.drawable.ball_football_icon, "Test de l'accelerometre",
					"capteur de mesure d'acceleration lineaire"));
			arrayList.add(new Test(2, R.drawable.cube_icon, "Test de rotation",
					"capteur de rotation"));
			arrayList.add(new Test(3, R.drawable.hand, "Test de proximite",
					"capteur de proximite face a un objet"));

			break;

		case 1:
			arrayList
					.add(new Test(4, R.drawable.gps, "Test GPS", "capteur de position GPS"));
			arrayList.add(new Test(5, R.drawable.boussole, "Test d'orientation",
					"capteur d'orientation (boussole)"));

			break;

		case 2:
			arrayList.add(new Test(6, R.drawable.degrade, "Test couleurs",
					"affichage du degrade de couleurs disponibles"));
			arrayList.add(new Test(7, R.drawable.tactile, "Test tactile",
					"capteur tactile de l'ecran"));

			break;

		case 3:
			arrayList.add(new Test(8, R.drawable.wifi, "Test WiFi", "test de fonctionnement de la connectique WiFi"));
			arrayList.add(new Test(9, R.drawable.bluetooth, "Test Bluetooth", "test de fonctionnement de la connectique Bluetooth"));

			break;

		case 4:
			arrayList.add(new Test(11, R.drawable.processor, "Analyse processeur", "test des perfomance du processeur"));
			arrayList.add(new Test(12, R.drawable.ram, "Analyse memoire systeme", "analyse de la memoire systeme"));
			arrayList.add(new Test(13, R.drawable.intern_memory, "Analyse memoire interne", "analyse de la memoire interne"));
			arrayList.add(new Test(14, R.drawable.sd_android, "Analyse memoire externe", "analyse de la memoire externe"));

			break;

		default:
			break;
		}

		bundle.putSerializable("array", arrayList);

		fragment = new FragmentListTests();
		fragment.setArguments(bundle);

		return fragment;
	}

	@Override
	public int getCount() {
		return MAX_TABS;
	}

	@Override
	public CharSequence getPageTitle(int position) {
		String title = "";
		switch (position) {
		case 0:
			title = "Mouvement";
			break;
		case 1:
			title = "Localisation";
			break;

		case 2:
			title = "Ecran";
			break;

		case 3:
			title = "Connexion";
			break;

		case 4:
			title = "Memoire";
			break;

		default:
			title = "Defaut";
			break;
		}

		return title;
	}
}
